home *** CD-ROM | disk | FTP | other *** search
/ MacGames Sampler / PHT MacGames Bundle.iso / MacSource Folder / Samples from the CD / 4thDimension / backup-restore-src.txt next >
Encoding:
Internet Message Format  |  1994-03-22  |  2.7 KB  |  [TEXT/EDIT]

  1. Date: Sat, 12 Jun 1993 09:04:52 -0800
  2. From: RPaige@ucsd.edu (Robert Paige)
  3. Subject: Re: Undo/Auto Backup
  4.  
  5. >2) You can set up a process that, at appointed hours, beams the data from
  6. >all fields in all datafiles into disk files stored elsewhere.  If you are
  7. >running v3 or server, this could take place unbeknownst to users.  The Send
  8. >Record command would work for this as long as the database structure would
  9. >not change between backup and restore.  Otherwise you would need to write
  10. >your own export procedure (more work).
  11.  
  12. The following should work to backup and restore your database, with the
  13. above restrictions. If you call these as a new process, they open their own
  14. progress windows:
  15.  
  16.   `Procedure: zBACKUP($1:pathname)
  17.  
  18.   `$1 = pathname to store files in
  19.  
  20.   `backs-up all the data files to external files in a selected folder
  21.  
  22. If (count parameters>=1)
  23.   $FolderPath:=$1
  24. else
  25.   `if $1 is not passed, files will be saved in same folder as
  26.   `structure (or 4D Client)
  27.   $FolderPath:=""
  28. end if
  29.  
  30. MESSAGES OFF  `4D progress messages
  31. MESSAGE("")  `open a default message window
  32. For ($FileNum;1;Count files)
  33.   SET WINDOW TITLE(Filename($FileNum)+": "+String($FileNum)+" of
  34. "+String(Count files))
  35.   $msg:="Backing-up "+String(Records in file(File($FileNum)>))+"
  36. Records"+Char(13)
  37.   MESSAGE($msg)
  38.   SET CHANNEL(12;$FolderPath+Filename($FileNum))
  39.   $FilePtr:=File($FileNum)
  40.   ALL RECORDS($FilePtr>)
  41.   APPLY TO SELECTION($FilePtr>;SEND RECORD($FilePtr>))
  42.   SET CHANNEL(11)
  43. End for 
  44.  
  45.  
  46.   `Procedure: zRESTORE($1:pathname)
  47.  
  48.   `$1 = pathname to get files from
  49.  
  50.   `restores the records in the data files from separate documents
  51.  
  52. If (count parameters>=1)
  53.   $FolderPath:=$1
  54. else
  55.   `if $1 is not passed, files will be retrieved from same folder as
  56.   `structure (or 4D Client)
  57.   $FolderPath:=""
  58. end if
  59.  
  60. MESSAGES OFF  `4D progress messages  
  61. MESSAGE("")  `open default message window
  62. For ($FileNum;1;Count files)
  63.   $FullPath:=$FolderPath+Filename($FileNum)
  64.   SET WINDOW TITLE(Filename($FileNum)+": "+String($FileNum)+" of
  65. "+String(Count files))
  66.   MESSAGE("Restoring File")
  67.   $FilePtr:=File($FileNum)
  68.   SET CHANNEL(10;$FullPath)
  69.   RECEIVE RECORD($FilePtr>)
  70.   $RecCount:=0
  71.   While (ok=1)
  72.     $RecCount:=$RecCount+1
  73.     SAVE RECORD($FilePtr>)
  74.     RECEIVE RECORD($FilePtr>)
  75.     If ($RecCount/10=Int($RecCount/10))  `display progress every 10 records
  76.       MESSAGE(String($RecCount)+" records restored.")
  77.     End if 
  78.   End while 
  79.   SET CHANNEL(11)
  80. End if 
  81. ----------------------------------------
  82. Robert Paige
  83. Internet: rpaige@ucsd.edu
  84. HIV Neurobehavioral Research Center
  85. Department of Psychiatry
  86. UCSD School of Medicine, San Diego, CA
  87. ----------------------------------------
  88.      >> Usual disclaimers apply. <<
  89. ----------------------------------------
  90.  
  91.  
  92.